﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartFront.Toolkit.ActionFramework
{
	public class ActionResultEventArgs<TResult> : EventArgs
	{
		 #region Properties

        /// <summary>
        /// Gets the result.
        /// </summary>
        /// <value>The result.</value>
		public TResult Result
		{
			get;
			private set;
		}

		/// <summary>
		/// Gets or sets the type.
		/// </summary>
		/// <value>The type.</value>
		public ActionCompletionType Type
		{
			get;
			private set;
		}

		/// <summary>
		/// Gets or sets the error.
		/// </summary>
		/// <value>The error.</value>
		public Exception Error
		{
			get;
			private set;
		}

        #endregion

        #region Constructor

        /// <summary>
        /// Initializes a new instance of the <see cref="ActionSuccessEventArgs&lt;TResult&gt;"/> class.
        /// </summary>
        /// <param name="result">The result.</param>
		public ActionResultEventArgs(TResult result)
        {
			Type = ActionCompletionType.Successed;
            this.Result = result;
        }

		/// <summary>
		/// Initializes a new instance of the <see cref="ActionResultEventArgs&lt;TResult&gt;"/> class.
		/// </summary>
		/// <param name="exception">The exception.</param>
		public ActionResultEventArgs(Exception exception)
		{
			Type = ActionCompletionType.Failed;
			this.Error = exception;
		}

        #endregion
	}
}
